clc
clear
close all
% 工况1 tf=1440
data1 = load('1440.mat');
time1 = data1.t;
V1 = data1.state(:, 4)*data1.Vs;
alt1 = (data1.state(:, 1) - 1)*data1.R0/1000;
fpa1 = data1.state(:, 5)*180/pi;
azi1 = data1.state(:, 6)*180/pi;
alpha1 = data1.ctrl(:, 1)*180/pi;
absBank1 = data1.ctrl(:, 2)*180/pi;
signOfBank1 = data1.ctrl(:, 3);
bank1 = absBank1.*signOfBank1;
lon1 = data1.state(:, 2)*180/pi;
lat1 = data1.state(:, 3)*180/pi;

% 工况2 tf=1460
data2 = load('1460.mat');
time2 = data2.t;
V2 = data2.state(:, 4)*data2.Vs;
alt2 = (data2.state(:, 1) - 1)*data2.R0/1000;
fpa2 = data2.state(:, 5)*180/pi;
azi2 = data2.state(:, 6)*180/pi;
alpha2 = data2.ctrl(:, 1)*180/pi;
absBank2 = data2.ctrl(:, 2)*180/pi;
signOfBank2 = data2.ctrl(:, 3);
bank2 = absBank2.*signOfBank2;
lon2 = data2.state(:, 2)*180/pi;
lat2 = data2.state(:, 3)*180/pi;

% 工况3 tf=1480
data3 = load('1480.mat');
time3 = data3.t;
V3 = data3.state(:, 4)*data3.Vs;
alt3 = (data3.state(:, 1) - 1)*data3.R0/1000;
fpa3 = data3.state(:, 5)*180/pi;
azi3 = data3.state(:, 6)*180/pi;
alpha3 = data3.ctrl(:, 1)*180/pi;
absBank3 = data3.ctrl(:, 2)*180/pi;
signOfBank3 = data3.ctrl(:, 3);
bank3 = absBank3.*signOfBank3;
lon3 = data3.state(:, 2)*180/pi;
lat3 = data3.state(:, 3)*180/pi;

f = figure('Name', '高度-时间历程');
plot(time1, alt1, time2, alt2,  '-.', time3, alt3, '--', 'linewidth', 1.5);hold;
xlabel('时间/s'); ylabel('高度/km');
legend('tf = 1440s', 'tf = 1460s', 'tf = 1480s');legend('boxoff');
a=1450;%圆心横坐标
b=28.5;%圆心纵坐标
c=40;%长半轴
d=1.5;%短半轴
theta=0:0.1:2*pi;
x=a+c*cos(theta);
y=b+d*sin(theta);
plot(x,y,'k:','HandleVisibility','off','linewidth', 1.5);
ax2 = axes('Position',[0.8 0.3 0.1 0.1]);
plot(ax2, time1, alt1, time2, alt2, '-.', time3, alt3, '--', 'linewidth', 1.5);
xlim([1400 1500])
ylim([27 30])
saveas(f, f.Name, 'svg')

f = figure('Name', '地面轨迹');
plot(lon1, lat1, lon2 , lat2, '-.', lon3, lat3, '--', 'linewidth', 1.5);
xlabel('经度/(deg)'); ylabel('纬度/(deg)');
legend('tf = 1440s', 'tf = 1460s', 'tf = 1480s','Location','northwest');
legend('boxoff');
ax2 = axes('Position',[0.75 0.6 0.15 0.15]);
plot(ax2, lon1, lat1, lon2 , lat2, '-.', lon3, lat3, '--', 'linewidth', 1.5);
xlim([49.9 50.1])
ylim([49.9 50.1])
saveas(f, f.Name, 'svg')

f = figure('Name', '速度-时间历程');
plot(time1, V1, time2, V2,'-.', time3, V3,  '--', 'linewidth', 1.5);
xlabel('时间/s)'); ylabel('速度/(m·s^{-1}）');
legend('tf = 1440s', 'tf = 1460s', 'tf = 1480s');legend('boxoff');
ax2 = axes('Position',[0.5 0.15 0.15 0.15]);
plot(time1, V1, time2, V2, '-.', time3, V3, '--', 'linewidth', 1.5);
xlim([1420 1490])
ylim([2000 2020])
saveas(f, f.Name, 'svg')

f = figure('Name', '航迹角-时间历程');
plot(time1, fpa1, time2, fpa2, '-.', time3, fpa3, '--', 'linewidth', 1.5);
legend('tf = 1440s', 'tf = 1460s', 'tf = 1480s');legend('boxoff');
xlabel('时间/s'); ylabel('航迹角/(deg)');
saveas(f, f.Name, 'svg')

f = figure('Name', '航向角-时间历程');
plot(time1, azi1, time2, azi2, '-.', time3, azi3, '--', 'linewidth', 1.5);
legend('tf = 1440s', 'tf = 1460s', 'tf = 1480s','Location','northwest');legend('boxoff');
xlabel('时间/s'); ylabel('航向角/(deg)');
saveas(f, f.Name, 'svg')

f = figure('Name', '攻角-时间历程');
plot(time1, alpha1, time2, alpha2, '-.', time3, alpha3, '--', 'linewidth', 1.5);
xlabel('时间/s'); ylabel('攻角/(deg)');
legend('tf = 1440s', 'tf = 1460s', 'tf = 1480s');legend('boxoff');
saveas(f, f.Name, 'svg')

f = figure('Name', '倾侧角-时间历程');
plot(time1, bank1, time2, bank2,  '-.', time3, bank3, '--', 'linewidth', 1.5);
xlabel('时间/s'); ylabel('倾侧角/(deg)');
legend('tf = 1440s', 'tf = 1460s', 'tf = 1480s');legend('boxoff');
saveas(f, f.Name, 'svg')